<template>
	<view class="goods-list">
		<view class="goods-list__box" v-for="(item, index) in listData" :key="index" @click="toNavigate(item)">
			<image class="goods-list__box__image" :src="item.recPic" mode="widthFix"></image>
			<view class="goods-list__box__right">
				<view class="goods-list__box__top">
					<view class="goods-list__box__title">{{ item.name }}</view>
				</view>
				<view class="goods-list__box__bot">
					<view v-if="item.unitPrice" class="goods-list__box__unitPrice">
						<span>￥</span>{{ item.unitPrice.toFixed(2) }}
					</view>
					<view v-if="type === 0" class="number">数量：{{ item.count }}</view>
					<view v-else class="look-detail">查看明细</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'goodsList',
		props: {
			listData: {
				type: [Array],
				default: []
			},
			type: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {}
		},
		methods: {
			// 商品详情
			toNavigate(item) {
				if (this.type === 0) {
					uni.navigateTo({
						url: '/pages/dissubmit/index?id=' + item.parentId
					})
				} else {
					uni.navigateTo({
						url: `/pages/disdetail/index?goodsId=${item.parentId}&type=${this.type}`
						// url: '/pages/sortdetail/index?goodsId=' + item.goodsId
					})
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.goods-list {

		.goods-list__box {
			width: 100%;
			height: 238rpx;
			margin-bottom: 24rpx;
			display: flex;
			justify-content: space-between;

			.goods-list__box__image {
				width: 200rpx;
				height: 200rpx;
				border-radius: 12rpx;
			}

			.goods-list__box__right {
				width: calc(100% - 200rpx - 16rpx);
				padding-bottom: 38rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				border-bottom: 1rpx solid #E2E2E2;
			}

			.goods-list__box__title {
				font-size: 28rpx;
				font-weight: bold;
				color: #333333;
				line-height: 40rpx;
				width: 100%;
				word-break: break-all;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				overflow: hidden;
			}

			.goods-list__box__bot {
				display: flex;
				align-items: center;
				justify-content: space-between;
			}

			.goods-list__box__unitPrice {
				font-size: 36rpx;
				font-weight: bold;
				color: #FB4041;

				span {
					font-size: 26rpx;
				}
			}

			.goods-list__box__unit {
				display: flex;
				align-items: center;

				.unit-icon {
					width: 54rpx;
					height: 54rpx;
				}

				.number {
					font-size: 30rpx;
					font-weight: bold;
					color: #333333;
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 0 20rpx;
				}
			}

		}

		.look-detail {
			width: 178rpx;
			height: 60rpx;
			background: #2FCC71;
			border-radius: 30rpx;
			font-size: 32rpx;
			font-weight: bold;
			color: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>